#include "quotefactory.h"
#include <qwt/qwt_date.h>

typedef struct
{
    int day;
    float open;
} Data;

 Data exampleData[] =
{
    { 3, 31.82},
    { 4, 31.96 },
    { 5, 32.45 },
    { 6, 32.65},
    { 7, 33.33 },
    { 10, 32.99 },
    { 11, 32.26},
    { 12, 31.03 },
    { 13, 31.61 },
    { 14, 32.05 },
    { 17, 31.82 },
    { 18, 32.33},
    { 19, 32.30 },
    { 20, 32.00 },
    { 21, 31.14 },
    { 24, 30.31 },
    { 25, 30.00 },
    { 26, 29.93 },
    { 27, 29.95},
    { 28, 29.90 },
    { 31, 30.69},
    { 32, 31.05 },
    { 33, 31.28},
    { 34, 31.32 },
    { 35, 30.25 },
    { 38, 30.00 },
    { 39, 29.75},
    { 40, 29.89 },
    { 41, 29.81 },
    { 42, 29.59 },
    { 45, 29.00},
    { 46, 28.90 },
    { 47, 29.68 },
    { 48, 29.58 },
    { 49, 29.22 },
    { 52, 30.65},
    { 53, 30.35 },
    { 54, 29.79 },
    { 55, 29.25},
    { 56, 29.69 },
    { 59, 30.20},
    { 60, 30.57 },
    { 61, 31.40 },
    { 62, 31.50},
    { 63, 31.63},
    { 66, 32.40 },
    { 67, 31.83},
    { 68, 32.06},
    { 69, 32.17},
    { 70, 32.85},
    { 73, 32.62 },
    { 74, 32.78},
    { 75, 32.83 },
    { 76, 32.43 },
    { 77, 32.42},
    { 80, 31.92},
    { 81, 32.69},
    { 82, 33.33},
    { 83, 33.50},
    { 84, 33.94 },
    { 87, 34.40 },
    { 88, 34.26 },
    { 89, 33.88 },
    { 90, 35.11 },
    { 95, 35.40},
    { 96, 35.34},
    { 97, 34.80 },
    { 98, 34.88 },
    { 101, 35.25 },
    { 102, 35.06},
    { 103, 35.06 },
    { 104, 35.59 },
    { 105, 35.15 },
    { 108, 35.45 },
    { 109, 36.56 },
    { 110, 36.75 },
    { 111, 36.63},
    { 112, 36.60 },
    { 115, 37.60 },
    { 116, 37.85},
    { 117, 36.80},
    { 118, 36.70 },
    { 119, 36.83},
    { 122, 37.08 },
    { 123, 37.51},
    { 124, 36.61},
    { 125, 35.45 },
    { 126, 35.78 },
    { 129, 36.23},
    { 130, 36.87},
    { 131, 37.97 },
    { 132, 39.35},
    { 133, 39.42 },
    { 136, 38.38},
    { 137, 39.10},
    { 138, 38.15},
    { 139, 37.44 },
    { 140, 36.20 },
    { 143, 36.30},
    { 144, 35.56},
    { 145, 35.80 },
    { 146, 36.30},
    { 147, 37.42 },
    { 150, 37.57 },
    { 151, 37.96 },
    { 152, 37.80 },
    { 153, 39.24 },
    { 154, 39.35 },
    { 157, 37.40 },
    { 158, 38.33 },
    { 159, 37.85 },
    { 160, 38.85},
    { 164, 40.59},
    { 165, 39.35},
    { 166, 40.18},
    { 167, 38.91 },
    { 168, 39.85},
    { 171, 41.70},
    { 172, 41.55},
    { 173, 41.11 },
    { 174, 41.97},
    { 175, 41.36},
    { 178, 40.66},
    { 179, 40.84 },
    { 180, 40.10},
    { 181, 39.56 },
    { 182, 38.83 },
    { 185, 38.10 },
    { 186, 38.29},
    { 187, 38.70},
    { 188, 39.62 },
    { 189, 39.30},
    { 192, 39.30 },
    { 193, 39.00},
    { 194, 42.42},
    { 195, 41.75 },
    { 196, 42.26 },
    { 199, 41.85 },
    { 200, 42.00},
    { 201, 41.30},
    { 202, 40.83 },
    { 203, 41.95 },
    { 206, 42.17 },
    { 207, 42.24 },
    { 208, 41.68 },
    { 209, 40.77},
    { 210, 40.44},
    { 213, 41.46 },
    { 214, 42.75},
    { 215, 43.14 },
    { 216, 43.69 },
    { 217, 44.90 },
    { 220, 44.49 },
    { 221, 44.35 },
    { 222, 43.05},
    { 223, 42.3},
    { 224, 42.02 },
    { 227, 42.08},
    { 228, 41.81},
    { 229, 43.02 },
    { 230, 43.68},
    { 231, 42.84 },
    { 234, 42.00 },
    { 235, 41.56 },
    { 236, 41.22},
    { 237, 41.56 },
    { 238, 41.60},
    { 241, 41.76 },
    { 242, 40.50 },
    { 243, 42.00},
    { 244, 42.64 },
    { 245, 43.60 },
    { 248, 44.17 },
    { 249, 43.97 },
    { 250, 43.72},
    { 251, 44.70 },
    { 252, 45.00 },
    { 255, 46.65 },
    { 256, 46.30 },
    { 257, 46.985 },
    { 258, 47.18},
    { 259, 47.81},
    { 262, 47.37 },
    { 263, 48.85},
    { 264, 48.48},
    { 265, 48.49},
    { 266, 48.09 },
    { 269, 50.15},
    { 270, 49.80 },
    { 271, 51.00 },
    { 272, 50.90 },
    { 273, 51.44},
    { 276, 49.06},
    { 277, 48.37},
    { 278, 49.77 },
    { 279, 49.31 },
    { 280, 50.26},
    { 283, 50.20 },
    { 284, 49.44 },
    { 285, 50.40},
    { 286, 50.50 },
    { 287, 50.08 },
    { 290, 49.23 },
    { 291, 48.99 },
    { 292, 49.09 },
    { 293, 49.54 },
    { 294, 50.19 },
    { 297, 50.31 },
    { 298, 50.49 },
    { 299, 50.04 },
    { 300, 50.15},
    { 301, 49.49},
    { 304, 51.77},
    { 305, 52.70},
    { 306, 50.75},
    { 307, 52.05},
    { 308, 54.14},
    { 311, 53.69},
    { 312, 53.40},
    { 313, 54.60},
    { 314, 54.00},
    { 315, 53.33},
    { 318, 55.07},
    { 319, 55.68},
    { 320, 54.72},
    { 321, 54.96},
    { 322, 56.34},
    { 325, 57.33},
    { 326, 57.15},
    { 327, 57.01},
    { 328, 59.10},
    { 329, 59.31},
    { 332, 59.75},
    { 333, 57.70},
    { 334, 58.35},
    { 335, 61.69},
    { 336, 63.70},
    { 339, 64.00},
    { 340, 63.00},
    { 341, 63.50},
    { 342, 62.42},
    { 343, 60.50},
    { 346, 62.00},
    { 347, 63.40},
    { 348, 62.00},
    { 349, 62.40 },
    { 350, 62.95 },
    { 353, 61.90},
    { 354, 63.40 },
    { 355, 64.98},
    { 356, 64.55},
    { 360, 62.70},
    { 361, 59.69 },
    { 362, 58.10},
    { 363, 59.10 }
};


QVector<QPointF> QuoteFactory::samplesData(  )
{
    const Data *data = NULL;
    int numSamples = 0;
    data = exampleData;
    numSamples = sizeof( exampleData ) / sizeof( Data );

    QVector<QPointF> samples;
    samples.reserve( numSamples );
    QDateTime year2014( QDate( 2014, 1, 1 ), QTime( 0, 0 ), Qt::UTC );
    for ( int i = 0; i < numSamples; ++i)
    {
        const Data &ohlc = data[ i ];
        samples += QPointF(QwtDate::toDouble( year2014.addSecs( ohlc.day ) ), ohlc.open );
    }

    return samples;
}

QString QuoteFactory::title()
{

    return "示例波形";
}
